package com.qiaoyanqing.ximalaya.discovermodule.discover_entity;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/11/9.
 */
public class Discover_RecommendBanner {

    private FocusImages mFocusImages;

    @Override
    public String toString() {
        return "Discover_RecommendBanner{" +
                "mFocusImages=" + mFocusImages +
                '}';
    }

    public FocusImages getFocusImages() {
        return mFocusImages;
    }

    public void setFocusImages(FocusImages focusImages) {
        mFocusImages = focusImages;
    }

    public static Discover_RecommendBanner parseString(String data){
        Discover_RecommendBanner discoverRecommendBanner =new Discover_RecommendBanner();
        try {
            JSONObject bannerJsonobject=new JSONObject(data);
            JSONObject focusImagesJsonObject = bannerJsonobject.optJSONObject("focusImages");
            FocusImages focusImages=new FocusImages();
            JSONArray focusImagejsonArray=focusImagesJsonObject.optJSONArray("list");
            List<Discover_Recommend_FocusImageBean>list=new ArrayList<>();
            for (int i = 0; i < focusImagejsonArray.length(); i++) {
                JSONObject jsonObject=focusImagejsonArray.optJSONObject(i);
                Discover_Recommend_FocusImageBean discoverRecommendFocusImageBean =new Discover_Recommend_FocusImageBean();
                discoverRecommendFocusImageBean.setPic(jsonObject.optString("pic"));
               list.add(discoverRecommendFocusImageBean);
            }
            focusImages.setList(list);
            discoverRecommendBanner.setFocusImages(focusImages);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        return discoverRecommendBanner;
    }

}
